#include <iostream>
#include <string>
/*
string类的构造函数：
string(const char *s);    //用c字符串s初始化
string(int n,char c);     //用n个字符c初始化
此外，string类还支持默认构造函数和复制构造函数，如string s1；string s2="hello"；都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常；


string的赋值：
string &operator=(const string &s);//把字符串s赋给当前字符串
string &assign(const char *s);//用c类型字符串s赋值
string &assign(const char *s,int n);//用c字符串s开始的n个字符赋值
string &assign(const string &s);//把字符串s赋给当前字符串
string &assign(int n,char c);//用n个字符c赋值给当前字符串
string &assign(const string &s,int start,int n);//把字符串s中从start开始的n个字符赋给当前字符串
string &assign(const_iterator first,const_itertor last);//把first和last迭代器之间的部分赋给字符串
*/


int main(int argc,char **argv)
{
	std::string aa = "abcd" ;
	std::string aa_1 = aa;
	char *cc_tmp = "abcd";
	char cc_tmp1[] = "abcd";
	std::string aa_2;

		std::cout <<"aa=" << aa << std::endl;
		std::cout <<"aa_1=" << aa_1 << std::endl;
		aa_2 = cc_tmp;
		std::cout <<"cc_tmp=" << cc_tmp << std::endl;
		std::cout <<"cc_tmp(aa_2)=" << aa_2 << std::endl;
		aa_2 = cc_tmp1;
		std::cout <<"cc_tmp1=" << cc_tmp1 << std::endl;
		std::cout <<"cc_tmp1(aa_2)=" << aa_2 << std::endl;

	std::string bb(4, 'a');
	std::string bb_1(aa);
	std::string bb_2("abcd");

		std::cout << "bb=" << bb << std::endl;
		std::cout << "bb_1=" << bb_1 << std::endl;
		std::cout << "bb_2=" << bb_2 << std::endl;

	std::string dd(aa, 2);
	std::string dd_1("abcd", 2);
	std::string dd_2(aa, 2, 1);
	std::string dd_3(aa, 2, 33);
	std::string dd_4(cc_tmp, cc_tmp+2);

	std::cout <<"dd=" << dd <<std::endl;
	std::cout << "dd_1=" << dd_1 << std::endl;
	std::cout <<"dd_2=" << dd_2 <<std::endl;
	std::cout << "dd_3=" << dd_3 << std::endl;
	std::cout << "dd_4=" << dd_4 << std::endl;

	return 0;
/*
--------------output begin-------------------

aa=abcd
aa_1=abcd
cc_tmp=abcd
cc_tmp(aa_2)=abcd
cc_tmp1=abcd
cc_tmp1(aa_2)=abcd
bb=aaaa
bb_1=abcd
bb_2=abcd
dd=cd
dd_1=ab
dd_2=c
dd_3=cd
dd_4=ab

--------------output end--------------------
*/


}
